//
//  GWPhotosCell.m
//  瀑布流
//
//  Created by qianfeng on 16/3/1.
//  Copyright (c) 2016年 高炜. All rights reserved.
//

#import "GWPhotosCell.h"
#import "GWWaterFllowView.h"
#import "UIImageView+WebCache.h"
#import "GWPhoto.h"
@interface GWPhotosCell ()
@property (nonatomic,weak)UIImageView *imageView;
@property (nonatomic,weak)UILabel *priceLabel;
@end
@implementation GWPhotosCell
+(GWPhotosCell *)cellWithWaterFloowView:(GWWaterFllowView *)waterFllowView
{
    GWPhotosCell *cell =[waterFllowView dequeueReusableCellWithIdentifier:@"WaterCell"];
    if (cell ==nil) {
        cell =[[GWPhotosCell alloc]init];
        cell.identifier =@"WaterCell";
        cell.backgroundColor =GWRandomColor;
        UILabel *label =[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 50, 20)];
        label.tag =300;
        [cell addSubview:label];
    }
    return cell;
}
-(instancetype)initWithFrame:(CGRect)frame
{
    if (self =[super initWithFrame:frame]) {
        UIImageView *imageView =[[UIImageView alloc]init];
        [self addSubview:imageView];
        self.imageView =imageView;
        
        UILabel *priceLabel =[[UILabel alloc]init];
        priceLabel.textColor =[UIColor whiteColor];
        priceLabel.backgroundColor =myColorRGBA(0, 0, 0, 0.3);
        priceLabel.font =[UIFont systemFontOfSize:13];
        priceLabel.textAlignment =NSTextAlignmentCenter;
        [self addSubview:priceLabel];
        self.priceLabel =priceLabel;
    }
    return self;
}
-(void)setPhoto:(GWPhoto *)photo
{
    _photo =photo;
    [self.imageView sd_setImageWithURL:[NSURL URLWithString:photo.img] placeholderImage:[UIImage imageNamed:@"loading"]];
    self.priceLabel.text =photo.price;
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    self.imageView.frame =self.bounds;
    self.priceLabel.frame =CGRectMake(0, self.height-25, self.width, 25);
}
@end
